import com.troyworks.framework.ui.BaseComponent;
import com.troyworks.hsmf.AEvent;
import util.IntrospectGraph;
import com.troyworks.framework.ui.IIntrospectableUIElement;
import com.troyworks.datastructures.Array2;
/**
 * @author Troy Gardner
 */
class com.troyworks.framework.ui.EditorBar extends BaseComponent {
	
	public var clips:Array2;
	public function EditorBar() {
		super(s1_buildingEditor, "EditorBar", false);
		clips = new Array2();
		init();
	}
	function onEditorChanged(evtd:Object):Void{
		 var objRef = evtd.activeObject;
					////////////////////////////////
		/*	var presentation = this.getBookPresentation();
			var slideList:Array = presentation.getSlideList();
			//     var slideList:Array = this.activeObject.getSlideList();
			_root.dataHolder.namesArray = slideList;
			trace("Slide Listing :_---------------");
			for (var i = 0; i<slideList.length; i++) {
				trace("Slide "+i+" "+slideList[i].name + " " + slideList[i].getSlideSWFLinkage());
			}*/
			//var editor:String = objRef.getEditorClipName();
		//	trace("editor mc  "+editor);
		//	var editorMC = (editor != null) ? (this.canvas[editor]) : (this.canvas.genericEditor_mc);
			//set all editors visibility false (remove)
			this._visible = true;
			//
			var opts:Array = objRef.getSupportedOperations();
			trace("000000000000000000000000000000000000000000000000000000");
trace("000000000000000000000000000000 HIGHLIGHTB  onEditorChanged 000000000000000000000000");
trace(util.Trace.me(opts, "opts", true));
trace("000000000000000000000000000000000000000000000000000000");
trace("000000000000000000000000000000000000000000000000000000");
trace("000000000000000000000000000000000000000000000000000000");
			for (var i in this.clips) {
				var _mc = this.clips.pop();
				trace("trying to remove "+_mc._name);
				_mc.removeMovieClip();
			}
			trace(opts.length+" supported operations");
			var lasX:Number = 0;
			for (var i = 0; i<opts.length; i++) {
				var opt = opts[i];
				trace("\t"+opt.label+" : "+opt.arg1);
				var d:Number = this.getNextHighestDepth();
				var _mc = this.attachMovie("Button", opt.label+"_btn", d);
				_mc.label = opt.label;
				//_mc.setLabel(_ary[i].name);
				_mc._x += lasX;
				_mc.setSize(120, 40);
				lasX += _mc._width+5;
				var obj:Object = new Object();
				obj.opt = opt;
				obj.owner = this;
				obj.click =function() {
					var me:Object = Object(this);
					trace("obj.click! "+me.opt.ptype);
					var res = me.opt.method.apply(me.opt.inst, me.opt.args);
					if(me.opt.help){
						trace("needing help from owner");
					}
					me.owner.modelChanged();
				};
				_mc.addEventListener("click", obj);
				this.clips.push(_mc);
			}
	}
	
	function s1_buildingEditor(e:AEvent):Void{
	}
	function s1_usingEditor(e:AEvent):Void{
	}
	function s1_destroyingEditor(e:AEvent):Void{
	}
}